<template>
	<view class="editInfoAreaWp">
		<view class="editInfoAreaList">
			<view class="editInfoAreaItem" v-for="(item,index) in list" :key="index">
				<view class="top" hover-class="hoverClass">
					<image class="topImg" :src="item.img" @click.stop="handleItem(item,index)">
					</image>
					<view class="title">
						{{item.title1}}
					</view>
				</view>
				<view class="main">
					<view class="title1">
						{{item.title1}}
					</view>
					<view class="title2">
						{{item.title2}}
					</view>
				</view>

			</view>

		</view>

	</view>
</template>

<script>
	import {
		editInfoAreaImgList,
	} from '@/config/staticConfig.js'
	export default {
		name: "editInfoAreaWp",
		data() {
			return {
				list: editInfoAreaImgList
			};
		},
		props: {
			myInfo: {
				type: Object,
				required: true
			}
		},

		methods: {
			handleItem(item, index) {
				if (!this.myInfo.id) {
					return uni.showToast({
						title: '请先创建名片',
						icon: 'none'
					})
				}
				// 管理员可以维护 商品 ,超管可以维护公司信息 ,商品
				switch (index) {
					case 0: //个人介绍
						this.$goToPage('/pagesCard/myProfile/myProfile?cardId=' + this.myInfo.id)
						break;
					case 1: //公司简介  超管才能修改公司简介 roleIdentify === 1)
						if (!this.myInfo.companyId || this.myInfo.companyId == null) {
							return uni.showToast({
								title: '请先创建或加入您的公司',
								icon: 'none'
							})
						}
						if (this.myInfo.companyId && this.myInfo.roleIdentify !== 1) {
							this.$goToPage('/pagesCard/companyInfo/companyInfo?id=' + this.myInfo.id)
						} else if (this.myInfo.companyId && this.myInfo.roleIdentify === 1) {
							this.$goToPage('/pagesParty/companyIndexAddOrEdit/companyIndexAddOrEdit')
						} else {
							uni.showToast({
								title: '暂未加入公司',
								icon: 'none'
							})
						}
						break;
						//产品服务

					case 2:
						if (!this.myInfo.companyId) {
							return uni.showToast({
								title: '请先创建或加入您的公司',
								icon: 'none'
							})
						} else {
							if (this.myInfo.roleIdentify == 0) {
								return this.$goToPage('/pages/product/product')
							}
							if (this.myInfo.roleIdentify == 1) {
								return this.$goToPage('/pagesCard/addProductManger/addProductManger')
							}
							if (this.myInfo.roleIdentify == 2) {
								return this.$goToPage('/pagesCard/addProductManger/addProductManger')
							}
						}

						break;
					default:
						break;
				}
			},
			goToCompanyManger() {
				if (!this.myInfo.companyId) {
					uni.navigateTo({
						url: `/pagesParty/companyAttestationAdd/companyAttestationAdd?currentCardId=${this.myInfo.id}`,

					})
					return
				}

				if (this.myInfo.companyId && this.myInfo.roleIdentify === 0) {
					uni.showToast({
						title: '需要管理员权限',
						icon: 'none'
					})
					return
				}

				uni.navigateTo({
					url: `/pagesParty/companyManger/companyManger`,
				})
			},


		}
	}
</script>

<style scoped lang="scss">
	.editInfoAreaWp {
		background-color: #F7F8FA;
		padding: 30rpx;

		.editInfoAreaList {
			display: flex;
			justify-content: space-between;
			align-items: center;
			flex-wrap: wrap;

			.editInfoAreaItem {
				width: 330rpx;
				height: 275rpx;
				background-color: #fff;
				border-radius: 8rpx 8rpx 8rpx 8rpx;
				margin-bottom: 30rpx;

				.top {
					width: 100%;
					height: 156rpx;
					position: relative;
					text-align: center;
					font-weight: 600;
					font-size: 36rpx;
					color: #FFFFFF;
					line-height: 50rpx;

					.topImg {
						width: 100%;
						height: 100%;
						position: absolute;
						left: 0
					}

					.title {
						font-size: 36rpx;
						font-weight: 600;
						color: #FFFFFF;
						line-height: 156rpx;
					}


				}

				.main {
					.title1 {
						margin-top: 10rpx;
						font-size: 28rpx;
						font-weight: 600;
						color: #1D2129;
						line-height: 39rpx;
						text-align: center;
					}

					.title2 {
						margin-top: 10rpx;
						font-size: 28rpx;
						font-weight: 400;
						color: #86909C;
						line-height: 39rpx;
						text-align: center;
					}

					.btn {
						margin: 12rpx auto;
						width: 158rpx;
						height: 56rpx;
						background: #ECF0F8;
						border-radius: 4rpx 4rpx 4rpx 4rpx;
						opacity: 1;
						border: 2rpx solid #ECF0F8;
						color: $u-primary;
						font-size: 28rpx;
					}

				}
			}
		}
	}
</style>